package com.filmbooks.fragment.mine.child;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.FrameLayout;

import com.filmbooks.R;
import com.zyw.horrarndoo.sdk.base.fragment.BaseCompatFragment;

import butterknife.BindView;

/**
 * Created by heshuxiang on 2018/3/2.
 * 描述：
 * 公司：盟将威
 * 作者：heshuxiang
 * 日期：2018/3/2.
 * 工程：FilmBooks
 * 包：com.filmbooks.fragment.mine.child
 */

public class MineFragment extends BaseCompatFragment {
    @BindView(R.id.fl_personal_container_upper)
    FrameLayout flPersonalContainerUpper;
    @BindView(R.id.fl_personal_container_lower)
    FrameLayout flPersonalContainerLower;
    @BindView(R.id.toolbar)
    Toolbar toolbar;

    @Override
    public int getLayoutId() {
        return R.layout.fragment_personal;
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        if (savedInstanceState == null) {
            loadFragment();
        } else {  // 这里可能会出现该Fragment没被初始化时,就被强杀导致的没有load子Fragment
            if (findChildFragment(MineUpperFragment.class) == null) {
                loadFragment();
            }
        }
    }

    private void loadFragment() {
        loadRootFragment(R.id.fl_personal_container_upper, MineUpperFragment.newInstance());
        loadRootFragment(R.id.fl_personal_container_lower, MineLowerFragment.newInstance());
    }

    @Override
    public void initUI(View view, @Nullable Bundle savedInstanceState) {
        toolbar.setTitle("我的");
    }

    public static MineFragment newInstance() {
        Bundle bundle = new Bundle();
        MineFragment fragment = new MineFragment();
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public boolean onBackPressedSupport() {
        //不处理，直接丢给Activity onBackPressedSupport处理
        //若此处要拦截回退逻辑到HomeFragment，直接使用RxBus处理
        return false;
    }
}
